package com.hoas.databox.demo;

import com.hoas.databox.core.EasyDataBox;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/databox/easybox")
public class EasyDataBoxController {

    @Autowired
    private EasyDataBox dataBox;

    @RequestMapping("/deposit")
    public String deposit(String data, int second) {

        return dataBox.deposit( data, second < 1 ? 1 : second);
    }

    @RequestMapping("/takeout")
    public String takeout(String ticket) {

        return dataBox.takeout( ticket );

    }

    @RequestMapping("/read")
    public String read(String ticket) {

        return dataBox.read( ticket );

    }

}
